// 消息提示工具类封装

import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

class ToastUtil {
  // 展示成功消息提示
  static showSuccess(String message) {
    Fluttertoast.showToast(
      msg: message,
      toastLength: Toast.LENGTH_SHORT, // 显示时长
      gravity: ToastGravity.BOTTOM, // 显示位置
      backgroundColor: Colors.green,
      textColor: Colors.white,
      // 针对web特殊配置，web显示背景色和显示位置
      webPosition: 'center',
      webBgColor: '#27BA9B',
    );
  }

  // 展示错误消息提示
  static showError(String message) {
    Fluttertoast.showToast(
      msg: message,
      toastLength: Toast.LENGTH_SHORT,
      gravity: ToastGravity.BOTTOM,
      backgroundColor: Colors.red,
      textColor: Colors.white,
      webPosition: 'center',
      webBgColor: '#FF4C4C',
    );
  }

  // 正常消息提示
  static showInfo(String message) {
    Fluttertoast.showToast(
      msg: message,
      toastLength: Toast.LENGTH_SHORT,
      gravity: ToastGravity.BOTTOM,
      backgroundColor: Colors.blue,
      textColor: Colors.white,
      webPosition: 'center',
      webBgColor: '#0000ff',
    );
  }
}
